<template>
  <section>
    <!-- 书名 -->
    <div class="book-box">
      <div class="book-name">
        <div><img :src="pic"/></div>
        <p class="book-title">{{details.class_title}}</p>
        <p><span class="gray">{{details.is_only ? '不独家': '独家'}}</span><span class="gray">{{details.is_only ? '不独家': '独家'}}</span></p>
        <p class="price"><span>￥{{details.price}}</span><span>特价仅剩7小时38分钟</span></p>
      </div>
    </div>
    <!-- 教师 -->
    <div class="teacher-part">
      <div class="teacher">
        <div class="teacher-msg">
          <img :src="details.img_url"/>
          <div>
            <p>{{details.teacher_name}}</p>
            <p>2884位学员</p>
          </div>
        </div>
        <a>进入网校</a>
      </div>
    </div>
    <!-- 课程介绍 -->
    <div class="course-part">
      <div class="course">
        <p class="title">课程介绍</p>
        <span class="gray">{{details.class_info}}</span>
      </div>
    </div>
  </section>
</template>

<script>
    export default {
      name: 'search-class-detail',
      data: function () {
        return {
          course_id: '',
          details: '',
          pic: ''
        }
      },
      watch: {
        '$route': 'getClassDetails'
      },
      mounted () {
        this.getClassDetails()
      },
      methods: {
        getClassDetails () {
          this.course_id = this.$route.params.course_id
          this.pic = this.$route.params.pic
          this.$http.post('http://134.175.237.162/index.php/Index/getClassDetails', 'course_id=' + this.course_id)
            .then((res) => {
              this.details = res.data.data
            }).catch(function (error) {
              console.log(error)
          })
        }
      }
    }
</script>

<style scoped>
  .book-box,
  .teacher-part,
  .course-part{
    background-color: #fff;
  }
  .book-name,
  .teacher,
  .course{
    margin: 0 auto;
    width: 90%;
  }
  /* 书名 */
  .book-name{
    background-color: #fff;
    display: flex;
    flex-direction: column;
    padding: 0.367rem;
  }
  .book-name img{
    width: 100%;
  }
  .book-title,
  .price span:first-child{
    padding: .77rem 0 .77rem 0;
    font-size: 1.5rem;
  }
  .book-name .gray{
    line-height: 1;
    color: #8891A7;
    border: 074rem solid #8891A7;
    border-radius: .147rem;
    margin-right: 0.5rem;
  }
  .price{
    border-top: 074rem solid #e6eaf2;
    display: flex;
    width: 100%;
    align-items: center;
    margin-top: 0.367rem;
  }
  .price span:last-child{
    border: .074rem solid #ff632a;
    color: #ff632a;
    margin-right: .29rem;
    padding: .22rem;
    margin-left: 1.1rem;
    font-size: .88rem;
  }
  /* 教师 */
  .teacher-part{
    margin-top: .6rem;
  }
  .teacher{
    display: flex;
    justify-content: space-between;
    align-content: center;
    padding: .9rem 0;
  }
  .teacher-msg{
    display: flex;
    align-content: center;
  }
  .teacher-msg img{
    width:3rem;
    height: 3rem;
    margin-right: .5rem;
  }
  .teacher-msg p{
    font-size: 1.15rem;
    color: #333740;
  }
  .teacher-msg p:last-child{
    font-size: .85rem;
  }
  .teacher a{
    color: #70788C;
  }
  /* 课程介绍 */
  .course,
  .hint{
    margin-top:1.53rem;
    padding-bottom: 1.15rem;
    border-bottom: 074rem solid #e6eae5;
  }
  .title{
    font-size: 1rem;
    padding-bottom: .5rem;
    font-weight: bold;
  }
  .gray{
    font-size: 1rem;
    color: #8f8f94;
  }
</style>
